Skip to content

Add test for ProtectedResourceMetadataParsing #1236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

yannj-fr
Copy link
Contributor

@yannj-fr yannj-fr commented Aug 4, 2025

Motivation and Context

Add tests cases for insurring ProtectedResourceMetadata validation is correctly done

How Has This Been Tested?

with pytest

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

@yannj-fr yannj-fr requested a review from a team as a code owner August 4, 2025 20:15
@yannj-fr yannj-fr requested a review from pcarleton August 4, 2025 20:15
@yannj-fr yannj-fr marked this pull request as draft August 4, 2025 20:35
@yannj-fr yannj-fr marked this pull request as ready for review August 4, 2025 20:36
Copy link
Member

@Kludex Kludex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is not testing the fact that the new fields are supported. It's testing that the class is properly validated, which it seems we are testing Pydantic here. The same can be said about the tests above.

I think an ideal test would be to use the new added literal fields in an auth flow. But that's an issue that comes from before, because we actually don't have tests for it...

Anyway, I'm okay with either merging or closing this.

yannj-fr and others added 2 commits August 5, 2025 12:10
Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>
Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>
Kludex
Kludex previously approved these changes Aug 5, 2025
@Kludex Kludex dismissed their stale review August 5, 2025 13:15

Actually, I don't think this is the way to go.

@yannj-fr
Copy link
Contributor Author

yannj-fr commented Aug 6, 2025

@Kludex tests updated

@yannj-fr
Copy link
Contributor Author

yannj-fr commented Aug 6, 2025

@Kludex done with the requested changes

Kludex
Kludex previously approved these changes Aug 6, 2025
@Kludex
Copy link
Member

Kludex commented Aug 6, 2025

Maybe we could benefit more if we move the test you added to a new file, so we can actually don't mix bad practices with good ones.

@yannj-fr
Copy link
Contributor Author

yannj-fr commented Aug 6, 2025

I will create a separated file, actually could be directly in the test/server/auth/test_proctected_resource.py

yannj-fr and others added 2 commits August 6, 2025 12:44
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
Kludex
Kludex previously approved these changes Aug 6, 2025
@yannj-fr
Copy link
Contributor Author

yannj-fr commented Aug 6, 2025

As per your advice, I removed the test that is just on the model, and fixed naming.
Just one question, it is not good practice to have test case in a class?

@Kludex
Copy link
Member

Kludex commented Aug 6, 2025

Just one question, it is not good practice to have test case in a class?

I don't think you get anything from it, it's more often seen in old test suites and when using unittest (https://docs.python.org/3/library/unittest.html#basic-example).

I prefer to stick with what modern packages do: not have wrapper classes.


This is my opinion tho.

@yannj-fr yannj-fr requested review from pcarleton and Kludex August 7, 2025 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants